/*
 * @Author: czy
 * @Date: 2021-07-15 11:51:36
 * @LastEditTime: 2021-07-15 15:42:01
 */
#include "sys/type.h"
#include "sys/system.h"

#include "../lib/scheduler.h"

void SJF_task_priority(PCB *task)
{
    if (task->running_times > 0)
    {
        if (task->last_run_time < 0)
        {
            task->total_run_time = 0;
            task->last_run_time = 0;
            task->running_times = 0;
        }
        task->priority = task->last_run_time * LAST_RUN_TIME_WWEIGHT + (task->total_run_time / task->running_times) * (1 - LAST_RUN_TIME_WWEIGHT);
    }
    else
    {
        task->priority = 1;
    }
}